<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>登录</title>
        <script src="js/jquery-3.3.1.js"></script>
        <script>
            $(function () {
                $("#checkCodeImg").click(function () {
                    this.src = "checkCodeServlet?time=" + new Date().getTime();
                });

                $("#loginForm").submit(function () {
                    $.post("user/login",$(this).serialize(),function (info) {
                        if(info.flag){
                            alert(info.data);
                            location.href = "user_list.html";
                        }else {
                            info.errorMsg;
                        }
                    });


                    return false;//禁止提交
                });

            });
        </script>
    </head>
    <body>
        <h3>登录</h3>
        <form id="loginForm">
            用户名:<input type="text" name="username"><br/>
            密码:<input type="password" name="password"><br/>
            验证码:<input type="text" name="checkCode"><img src="checkCodeServlet" id="checkCodeImg"><br/>
            记住:<input type="checkbox" name="remember"><br/>
            <input type="submit" value="登录">
        </form>
    </body>
</html>
